package com.xyhy.core.base.lookup;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import com.xyhy.core.base.entity.NamedObject;

public class LookupObject extends LookupKeyVal<Long> {

  public LookupObject() {
  }

  public LookupObject(Long id, String name) {
    super(id, name);
  }

  public LookupObject(NamedObject<Long> entity) {
    super(entity.getId(), entity.getName());
  }

  public static <T extends NamedObject<Long>> List<LookupObject> values(List<T> datas) {
    return datas.stream().map(x -> new LookupObject(x.getId(), x.getName())).collect(Collectors.toList());
  }

  @Override
  public Long getId() {
    return id;
  }

  @Override
  public int hashCode() {
    return Objects.hashCode(id);
  }

}
